package com.yanfan.energy.service.impl;

import java.util.List;
import com.yanfan.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.energy.mapper.IbmsEnergyDeviceDataMapper;
import com.yanfan.energy.domain.IbmsEnergyDeviceData;
import com.yanfan.energy.service.IIbmsEnergyDeviceDataService;

/**
 * 能耗设备数据Service业务层处理
 *
 * @author genluo
 * @date 2024-09-22
 */
@Service
public class IbmsEnergyDeviceDataServiceImpl extends ServiceImpl<IbmsEnergyDeviceDataMapper, IbmsEnergyDeviceData> implements IIbmsEnergyDeviceDataService {
    @Autowired
    private IbmsEnergyDeviceDataMapper ibmsEnergyDeviceDataMapper;


    /**
     * 查询能耗设备数据列表
     *
     * @param ibmsEnergyDeviceData 能耗设备数据
     * @return 能耗设备数据
     */
    @Override
    public List<IbmsEnergyDeviceData> queryPageList(IbmsEnergyDeviceData ibmsEnergyDeviceData) {
        LambdaQueryWrapper<IbmsEnergyDeviceData> lqw = buildQueryWrapper(ibmsEnergyDeviceData);
//        return ibmsEnergyDeviceDataMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        return ibmsEnergyDeviceDataMapper.queryPageList(ibmsEnergyDeviceData);
    }

    /**
     * 分页查询条件
     * @return
     */
    private LambdaQueryWrapper<IbmsEnergyDeviceData> buildQueryWrapper(IbmsEnergyDeviceData bo) {
        LambdaQueryWrapper<IbmsEnergyDeviceData> lqw = Wrappers.lambdaQuery();
//        lqw.eq(StringUtils.isNotBlank(bo.getDeviceId()), IbmsEnergyDeviceData::getDeviceId, bo.getDeviceId());
        lqw.eq(StringUtils.isNotBlank(bo.getIdentifier()), IbmsEnergyDeviceData::getIdentifier, bo.getIdentifier());
        lqw.eq(StringUtils.isNotBlank(bo.getValue()), IbmsEnergyDeviceData::getValue, bo.getValue());

        lqw.eq(StringUtils.isNotBlank(bo.getDeviceName()), IbmsEnergyDeviceData::getDeviceName, bo.getDeviceName());
        lqw.eq(StringUtils.isNotBlank(bo.getDeviceType()), IbmsEnergyDeviceData::getDeviceType, bo.getDeviceType());

        lqw.eq(StringUtils.isNotBlank(bo.getTime()), IbmsEnergyDeviceData::getTime, bo.getTime());
        lqw.eq(StringUtils.isNotBlank(bo.getCreatedAt()), IbmsEnergyDeviceData::getCreatedAt, bo.getCreatedAt());
        lqw.eq(bo.getUpdatedAt() != null, IbmsEnergyDeviceData::getUpdatedAt, bo.getUpdatedAt());
        return lqw;
    }



}
